package com.exchange.repository;

import com.exchange.entity.Product;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ProductRepository extends JpaRepository<Product, Long> {
    List<Product> findByMerchantId(Long merchantId);
    
    @Query("SELECT COUNT(p) FROM Product p WHERE p.merchantId = :merchantId")
    Long countByMerchantId(@Param("merchantId") Long merchantId);
    
    @Query("SELECT p FROM Product p WHERE p.merchantId = :merchantId AND p.status = :status")
    List<Product> findByMerchantIdAndStatus(@Param("merchantId") Long merchantId, @Param("status") Product.ProductStatus status);
}